package kz.simplex.photobox.model;
// Generated Jul 19, 2009 4:45:38 PM by Hibernate Tools 3.2.2.GA

import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;

/**
 * Comments generated by hbm2java
 */
@Entity
@Table(name = "comments", catalog = "photobox")
public class Comment implements java.io.Serializable {
	private Integer id;
	private Comment answerTo;
	private Photo photo;
	private User author;
	private String content;
	private Date added = new Date();

	public Comment() {
	}

	public Comment(Photo photo, User author, String content, Date added) {
		this.photo = photo;
		this.author = author;
		this.content = content;
		this.added = added;
	}
	public Comment(Comment answerTo, Photo photo, User author, String content,
			Date added) {
		this.answerTo = answerTo;
		this.photo = photo;
		this.author = author;
		this.content = content;
		this.added = added;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}
	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne
	@JoinColumn(name="answerto", referencedColumnName="id", nullable = true)
	public Comment getAnswerTo() {
		return this.answerTo;
	}
	public void setAnswerTo(Comment answerTo) {
		this.answerTo = answerTo;
	}

	@ManyToOne
	@JoinColumn(name="photo", referencedColumnName="id", nullable = false)
	public Photo getPhoto() {
		return this.photo;
	}
	public void setPhoto(Photo photo) {
		this.photo = photo;
	}

	@ManyToOne
	@JoinColumn(name="author", referencedColumnName="id", nullable = false)
	public User getAuthor() {
		return this.author;
	}
	public void setAuthor(User author) {
		this.author = author;
	}

	@Column(name = "content", nullable = false, length = 65535)
	@NotNull
	@Length(max = 65535)
	public String getContent() {
		return this.content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "added", nullable = false, length = 19)
	@NotNull
	public Date getAdded() {
		return this.added;
	}
	public void setAdded(Date added) {
		this.added = added;
	}

}
